home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
Carousel
/
CAROUSEL.cdr
/
mactosh
/
lang
/
lsc30p4u.sit
/
IMPORTANT - READ THIS!
next >
Wrap
Text File
|
1989-01-16
|
5KB
|
128 lines
Change in Exit Handling
1/16/89
It is IMPERATIVE that you apply the library changes, included in this
package, when you apply the 3.01p4 patch. The old libraries are
incompatible with the new compiler.
Also, this memo contains critical information concerning the behavior of
your application when it exits. This is information which you MUST KNOW
if:
(1a) You call the standard library function "onexit", or you use
stdio, the profiler, or "signal" (each of which calls "onexit").
-or-
(1b) You build applications with the "Separate STRS" option set.
(This option is frequently set in projects which originated
prior to THINK C 3.0.)
-and-
(2) Your application can exit by calling "Launch" (or "_Launch").
(For example, your application may implement a "Transfer"
menu.)
If you don't use "Launch", or you don't use "onexit" or "Separate STRS",
then you can get away without reading the rest of this. But please be
sure to update your libraries no matter what!
BACKGROUND
----------
The manner in which THINK C applications clean up when they exit has
changed in version 3.01p4. When using this version (or later), it is
critical that you avoid using earlier versions of the standard libraries,
as the implementation of "onexit" has changed in an incompatible way.
In addition, it can no longer be guaranteed that your application will
be able to clean up if it exits with a "Launch". This may be an issue
if you are relying on "onexit" to schedule clean-up. Even if you're not
using "onexit", the runtime system for applications built with "Separate
STRS" has clean-up of its own to perform at exit.
Previously, the runtime system built into every THINK C application was
able to arrange for clean-up no matter how the application might exit.
Unfortunately, the method used to assure this resulted in applications
which were not "32-bit clean".
The new method is 32-bit clean, but can't catch the case where the
application exits with a "Launch". (Actually, even this case is caught
if the application is running under MultiFinder -- though this can't be
guaranteed for future versions of MultiFinder.)
WAYS OF EXITING
---------------
Let's define some terms:
"normal exit"
If your application exits by calling the "exit" function, or
by returning from "main", this is considered a normal exit.
"abnormal exit"
If your application exits by calling "ExitToShell", this is
considered an abnormal exit. Calling "abort" is covered under
this definition, as is terminating execution under the control
of a debugger. (Under the CURRENT implementation of MultiFinder,
all exits are either normal or abnormal -- even "SysError" ends
up calling "ExitToShell"!)
"unsafe exit"
If your application exits by calling "Launch", or in any other
manner not covered above, this is considered an unsafe exit.
ONEXIT AND _ONEXIT
------------------
Routines registered with "onexit" will now be called only on normal exits.
Previously, they were called on any form of exit.
A new routine, "_onexit", is now available. Routines registered with
"_onexit" will be called on abnormal as well as normal exits.
To summarize:
(1) On a normal exit, routines registered with "onexit" or
"_onexit" will be called.
(2) On an abnormal exit, routines registered with "_onexit"
will be called. Routines registered with "onexit" will
NOT be called.
In both of these cases, the runtime support for "Separate STRS" will be
given a chance to clean up. (This happens even if you never register any
clean-up routines of your own.)
DEALING WITH UNSAFE EXITS
-------------------------
If an unsafe exit is taken, no clean-up routines will be called. If you
have registered essential clean-up routines (e.g. removing trap intercepts
or other low-memory vectors), or if your application is built using
"Separate STRS", this could be disastrous.
To deal with this, a new routine, "_exiting", is now available. This
function performs all appropriate clean-up, but doesn't actually exit.
It should be called before initiating an unsafe exit, e.g. before calling
"Launch".
"_exiting" takes an argument indicating whether the clean-up should be
that associated with a normal or an abnormal exit. A non-zero argument
indicates a normal exit.
If your application never calls "onexit" or "_onexit" (and doesn't use
stdio, the profiler, or "signal", which do), AND if your application is
not built with "Separate STRS", then you needn't bother with "_exiting".
The "exec" series of standard library functions call "_exiting(1)".